package org.nci.platform.workflow.expand.system.service.impl;

import com.alibaba.fastjson2.JSON;
import gh.priv.general.common.vo.PageResult;
import org.nci.platform.workflow.dto.FlowRolePageQuery;
import org.nci.platform.workflow.dto.FlowRoleQuery;
import org.nci.platform.workflow.expand.system.entity.WorkflowRole;
import org.nci.platform.workflow.expand.system.service.WorkflowRoleService;

import java.util.List;
import java.util.Objects;

public class DemoRoleImpl implements WorkflowRoleService {
    String data = "[{\"roleId\":\"role_3001\",\"roleName\":\"前台接待\"},{\"roleId\":\"role_3002\",\"roleName\":\"客房服务\"},{\"roleId\":\"role_3003\",\"roleName\":\"餐饮服务\"},{\"roleId\":\"role_3004\",\"roleName\":\"财务管理\"},{\"roleId\":\"role_3005\",\"roleName\":\"行政管理\"}]";

    @Override
    public List<WorkflowRole> selectRoleList(FlowRoleQuery role) {
        return JSON.parseArray(data,WorkflowRole.class);
    }

    @Override
    public WorkflowRole selectRoleById(String roleId) {
        List<WorkflowRole> workflowRoles = selectRoleList(null);
        return workflowRoles.stream().filter(r-> Objects.equals(r.getRoleId(), roleId)).findFirst().orElse(new WorkflowRole());
    }

    @Override
    public PageResult<WorkflowRole> selectRolePage(FlowRolePageQuery query) {
        List<WorkflowRole> workflowRoles = selectRoleList(null);
        return PageResult.of(workflowRoles,workflowRoles.size(),workflowRoles.size(),1);
    }
}
